layui.define(['layer', 'jquery', 'table', 'element'], function (exports) {
    // 初始化组件
    var $ = layui.jquery,
        form = layui.form,
        table = layui.table,
        element = layui.element;

    var downing = false;
    var downthread = '';

    // 功能
    var lycms = {
        // 页面刷新
        pageRefreshs: function (index = null) {
            setTimeout(function () {
                $('#data-refresh').click();
                layer.close(index);
            }, 1200);
        },

        //加载动画
        loading: function (type = 0, shade = false) {
            var load = layer.load(type, {
                shade: shade
            });
            return load;
        },

        // 页面刷新带动画
        pageRefresh: function (type = 0, shade = false) {
            var index = lycms.loading(type, shade);
            lycms.pageRefreshs(index);
        },

        // APP设置
        appsetOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/appset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // API设置
        apisetOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/apiset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 邮件设置
        emailOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/emailset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        //导航设置 
        navsetOperate: function (data) {
            var result = JSON.stringify(data.field);
            $.ajax({
                url: "/ask/action/system/nav/add",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        }, function () {
                            lycms.pageRefresh();
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 密码设置
        passwdOperate: function (data) {
            $.post("/ask/action/system/passwd/edit", data.field, function (data, status) {
                if (data.code == "200") {
                    layer.msg(data.msg, {
                        time: 1500
                    }, function () {
                        window.location = '/admin/logout';
                    });
                } else {
                    layer.msg(data.msg, {
                        time: 1500
                    });
                }
            });
        },

        // 专题设置
        plateaddOperate: function (data) {
            if (data.field.method == undefined) {
                layer.msg("采集方法不能为空");
                return;
            }
            $.ajax({
                url: "/ask/action/system/special/add",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        }, function () {
                            window.location = '/admin/index#/platelist';
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 播放器设置
        playerOperate: function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                //编辑
                var content = miniPage.getHrefContent('page/table/add.html');
                var openWH = miniPage.getOpenWidthHeight();
                var index = layer.open({
                    title: '编辑用户',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;

            } else if (obj.event === 'delete') {
                //删除
                layer.confirm('真的删除吗?', {
                    title: "提示"
                }, function (index) {
                    obj.del();
                    //关闭提示框
                    layer.close(index);
                    //删除
                    $.post("/ask/action/system/player/del", {
                        id: data.inc_id
                    }, function (data, status) {
                        if (data.code == "200") {
                            layer.msg(data.msg, {
                                time: 1500
                            }, function () {
                                lycms.pageRefresh();
                            });
                        } else {
                            layer.msg(data.msg, {
                                time: 1500
                            });
                        }
                    });
                });
            }
        },

        // SEO设置
        seoOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/seoset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 通讯设置
        socketOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/socket",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 提示设置
        tipssetOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/tipsset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        //网站设置
        websetOperate: function (data) {
            $.ajax({
                url: "/ask/action/system/webset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
        },

        // 会员操作
        userOperate: function (obj, dom, filter) {
            // 行数据
            var data = obj.data;
            // 判断操作类型
            if (obj.event === 'edit') {
                // 载入模态框
                var index = layer.open({
                    title: '会员编辑',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    content: $(dom).html(),
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        form.render();
                        form.on("submit(" + filter + ")", function (reslue) {
                            // 生成提交数据
                            var editdata = {
                                passwd: reslue.field.passwd,
                                points: reslue.field.points,
                                nick: reslue.field.nick,
                                id: data.id
                            };
                            // 发送修改请求
                            $.ajax({
                                url: "/ask/action/system/user/edit",
                                type: "post",
                                timeout: 5000,
                                dataType: "json",
                                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                                data: editdata,
                                success: function (res) {
                                    // 判断返回响应
                                    if (res.code == 200) {
                                        // 弹出提示
                                        layer.msg(res.msg, {
                                            time: 1000
                                        }, function () {
                                            layer.close(index); //关闭弹层
                                            lycms.pageRefresh();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                    }
                                },
                                error: function (XMLResponse) {
                                    //异常捕获
                                    layer.msg(XMLResponse.responseText);
                                }
                            });
                        });

                        $("#" + filter).click();
                    }, //载入模态框初始化
                    success: function (layero, index) {
                        // 载入初始数据
                        form.val('bannerset', data);
                        // 刷新表单
                        form.render();
                    }
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('确定删除吗？', function (index) {
                    var did = {
                        id: data.id
                    }
                    $.ajax({
                        url: "/ask/action/system/user/del", //url
                        type: "post",
                        timeout: 5000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            if (res.code == 200) {
                                obj.del();
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            } else {
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            }
                        }
                    })
                });
                return false;
            }
        },

        // 轮播操作
        bannerOperate: function (obj, dom, filter) {
            // 行数据
            var data = obj.data;
            // 判断操作类型
            if (obj.event === 'edit') {
                // 载入模态框
                var index = layer.open({
                    title: '轮播编辑',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    content: $(dom).html(),
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        form.render();
                        form.on("submit(" + filter + ")", function (reslue) {
                            // 生成提交数据
                            var editdata = {
                                title: reslue.field.title,
                                pic: reslue.field.pic,
                                url: reslue.field.url,
                                id: data.id
                            };
                            // 发送修改请求
                            $.ajax({
                                url: "/ask/action/system/banner/edit",
                                type: "post",
                                timeout: 5000,
                                dataType: "json",
                                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                                data: editdata,
                                success: function (res) {
                                    // 判断返回响应
                                    if (res.code == 200) {
                                        // 弹出提示
                                        layer.msg(res.msg, {
                                            time: 1000
                                        }, function () {
                                            layer.close(index); //关闭弹层
                                            lycms.pageRefresh();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                    }
                                },
                                error: function (XMLResponse) {
                                    //异常捕获
                                    layer.msg(XMLResponse.responseText);
                                }
                            });
                        });

                        $("#" + filter).click();
                    }, //载入模态框初始化
                    success: function (layero, index) {
                        // 载入初始数据
                        form.val('bannerset', data);
                        // 刷新表单
                        form.render();
                    }
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('确定删除吗？', function (index) {
                    var did = {
                        id: data.id
                    }
                    $.ajax({
                        url: "/ask/action/system/banner/del", //url
                        type: "post",
                        timeout: 5000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            if (res.code == 200) {
                                obj.del();
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            } else {
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            }
                        }
                    })
                });
                return false;
            }
        },

        // 侵权操作
        tortOperate: function (obj, dom, filter) {
            // 行数据
            var data = obj.data;
            // 判断操作类型
            if (obj.event === 'edit') {
                // 载入模态框
                var index = layer.open({
                    title: '轮播编辑',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    content: $(dom).html(),
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        form.render();
                        form.on("submit(" + filter + ")", function (reslue) {
                            // 生成提交数据
                            var editdata = {
                                title: reslue.field.title,
                                pic: reslue.field.pic,
                                url: reslue.field.url,
                                id: data.id
                            };
                            // 发送修改请求
                            $.ajax({
                                url: "/ask/action/system/tort/edit",
                                type: "post",
                                timeout: 5000,
                                dataType: "json",
                                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                                data: editdata,
                                success: function (res) {
                                    // 判断返回响应
                                    if (res.code == 200) {
                                        // 弹出提示
                                        layer.msg(res.msg, {
                                            time: 1000
                                        }, function () {
                                            layer.close(index); //关闭弹层
                                            lycms.pageRefresh();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                    }
                                },
                                error: function (XMLResponse) {
                                    //异常捕获
                                    layer.msg(XMLResponse.responseText);
                                }
                            });
                        });

                        $("#" + filter).click();
                    }, //载入模态框初始化
                    success: function (layero, index) {
                        // 载入初始数据
                        form.val('bannerset', data);
                        // 刷新表单
                        form.render();
                    }
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('确定删除吗？', function (index) {
                    var did = {
                        id: data.id
                    }
                    $.ajax({
                        url: "/ask/action/system/tort/del", //url
                        type: "post",
                        timeout: 5000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            if (res.code == 200) {
                                obj.del();
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            } else {
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            }
                        }
                    })
                });
                return false;
            }
        },

        // 广告操作
        adOperate: function (obj, dom, filter) {
            // 行数据
            var data = obj.data;

            // 判断操作类型
            if (obj.event === 'edit') {
                // 载入模态框
                var index = layer.open({
                    title: '轮播编辑',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    content: $(dom).html(),
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {

                        form.render();
                        form.on("submit(" + filter + ")", function (reslue) {
                            // 生成提交数据
                            var editdata = {
                                title: reslue.field.title,
                                bindColumn: reslue.field.bindColumn,
                                sort: reslue.field.sort,
                                code: reslue.field.code,
                                id: data.id
                            };
                            // 发送修改请求
                            $.ajax({
                                url: "/ask/action/system/ad/edit",
                                type: "post",
                                timeout: 5000,
                                dataType: "json",
                                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                                data: editdata,
                                success: function (res) {
                                    // 判断返回响应
                                    if (res.code == 200) {
                                        // 弹出提示
                                        layer.msg(res.msg, {
                                            time: 1000
                                        }, function () {
                                            layer.close(index); //关闭弹层
                                            lycms.pageRefresh();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                    }
                                },
                                error: function (XMLResponse) {
                                    //异常捕获
                                    layer.msg(XMLResponse.responseText);
                                }
                            });
                        });

                        $("#" + filter).click();
                    }, //载入模态框初始化
                    success: function (layero, index) {
                        $.post("/v1/admin/data/platelist", function (re, status) {
                            re.data.forEach(element => {
                                var option = '<option value="' + element.alias + '">' + element.title + '</option>';
                                $("#bindColumn").append(option);
                            });
                            form.render();
                        });
                        // 载入初始数据
                        form.val('bannerset', {
                            'title': data.title,
                            'bindColumn': data.column,
                            'sort': data.sort,
                            'code': data.content,
                        });
                        // 刷新表单
                        form.render();
                    }
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('确定删除吗？', function (index) {
                    var did = {
                        id: data.id
                    }
                    $.ajax({
                        url: "/ask/action/system/ad/del", //url
                        type: "post",
                        timeout: 5000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            if (res.code == 200) {
                                obj.del();
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            } else {
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            }
                        }
                    })
                });
                return false;
            }
        },

        // 商城操作
        millOperate: function (obj, dom, filter) {
            // 行数据
            var data = obj.data;
            // 判断操作类型
            if (obj.event === 'edit') {
                // 对话框
                layer.confirm('是否安装[' + data.title + '-' + data.edition + ']到你的程序！', {
                    icon: 1,
                    title: "安装"
                }, function (index) {

                    // 判断任务已存在
                    if ($('#dowming').length > 0) {
                        layer.msg("请等待当前任务完成！");
                        return false;
                    }

                    var did = {
                        id: data.id,
                        type: "install"
                    }
                    var page = layer.open({
                        type: 1,
                        title: '正在安装...',
                        shade: 0,
                        maxmin: true,
                        content: $(dom).html(),
                        zIndex: layer.zIndex, //重点1
                        success: function (layero) {
                            layer.setTop(layero); //重点2
                            var othis = $(this);
                            active.loading.call(this, othis);
                            // 发起安装请求
                            $.ajax({
                                url: "/action/system/install", //url
                                type: "post",
                                timeout: 1000000,
                                dataType: "json",
                                data: did,
                                success: function (res) {
                                    res = JSON.parse(res);
                                    downing = true;
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        }, function () {
                                            layer.close(page);
                                        });
                                        layer.close(page);
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                        layer.close(page);
                                    }
                                },
                                error: function (XMLResponse) {
                                    layer.msg("云端失去连接！", {
                                        time: 1500
                                    });
                                    layer.close(page);
                                }
                            })
                        }
                    });
                    layer.close(index);
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('你真的要卸载[' + data.title + '-' + data.edition + ']吗？', {
                    icon: 2,
                    title: "卸载"
                }, function (index) {
                    var did = {
                        id: data.id,
                        type: "uninstall"
                    }
                    $.ajax({
                        url: "/action/system/install", //url
                        type: "post",
                        timeout: 1000000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            res = JSON.parse(res);
                            if (res.code == 200) {
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function () {
                                    lycms.pageRefresh();
                                });

                            } else {
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function () {
                                    lycms.pageRefresh();
                                });
                            }
                        },
                        error: function (XMLResponse) {
                            layer.msg("未知错误", {
                                time: 1000
                            }, function () {
                                lycms.pageRefresh();
                            });
                        }
                    })
                    layer.close(index);
                });
                return false;
            }
        },

        // 留言操作
        sayOperate: function (obj, dom, filter, check) {
            // 行数据
            var data = obj.data;
            // 判断操作类型
            if (obj.event === 'edit') {
                // 载入模态框
                var index = layer.open({
                    title: '留言回复',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    content: $(dom).html(),
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        form.render();
                        form.on("submit(" + filter + ")", function (reslue) {
                            // 生成提交数据
                            var editdata = {
                                content: reslue.field.content,
                                id: data.id
                            };
                            // 发送修改请求
                            $.ajax({
                                url: "/ask/action/system/say/add",
                                type: "post",
                                timeout: 5000,
                                dataType: "json",
                                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                                data: editdata,
                                success: function (res) {
                                    // 判断返回响应
                                    if (res.code == 200) {
                                        // 弹出提示
                                        layer.msg(res.msg, {
                                            time: 1000
                                        }, function () {
                                            layer.close(index); //关闭弹层
                                            lycms.pageRefresh();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            time: 1500
                                        });
                                    }
                                },
                                error: function (XMLResponse) {
                                    //异常捕获
                                    layer.msg(XMLResponse.responseText);
                                }
                            });
                        });

                        $("#" + filter).click();
                    }, //载入模态框初始化
                    success: function (layero, index) {
                        // 刷新表单
                        form.render();
                    }
                });
                return false;
                //删除操作
            } else if (obj.event === 'delete') {
                // 对话框
                layer.confirm('确定删除吗？', {
                    title: "删除"
                }, function (index) {
                    var did = {
                        id: data.id
                    }
                    $.ajax({
                        url: "/ask/action/system/say/del", //url
                        type: "post",
                        timeout: 5000,
                        dataType: "json",
                        data: did,
                        success: function (res) {
                            if (res.code == 200) {
                                obj.del();
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            } else {
                                layer.msg(res.msg, {
                                    time: 1500
                                });
                                layer.close(index);
                            }
                        }
                    })
                });
                return false;
            } else if (obj.event === 'check') {
                var index = layer.open({
                    title: '留言',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    content: $(check).html(),
                    btn: ['确定', '取消'],
                    yes: function () {
                        layer.close(index); //关闭弹层
                    },
                    success: function (layero, index) {
                        $.post("/v1/admin/data/sayinfo", {
                            id: data.id
                        }, function (re, status) {
                            re.forEach(element => {
                                var html = saydom.code(element.time, element.content);
                                $("#sayLi").append(html);
                            });
                            form.render();
                        });
                    }
                });
            }
        },

        // 多个方法测试
        put: function () {},
    }

    // 留言详情构建器
    var saydom = {
        code: function (title, content) {
            var a1 = '<li class="layui-timeline-item">';
            var a2 = '<i class="layui-icon layui-timeline-axis"></i>';
            var a3 = '<div class="layui-timeline-content layui-text">';
            var a4 = '<h3 class="layui-timeline-title">' + title + '</h3>';
            var a5 = ' <p>' + content + '</p> </div> </li>';
            var a6 = a1 + a2 + a3 + a4 + a5;
            return a6;
        }
    }

    //触发事件
    var active = {
        setPercent: function () {
            //设置50%进度
            element.progress('downLoad', '50%')
        },
        loading: function (othis) {
            var DISABLED = 'layui-btn-disabled';
            if (othis.hasClass(DISABLED)) return;
            //模拟loading
            var n = 0,
                timer = setInterval(function () {
                    n = n + Math.random() * 50 | 0;
                    if (n > 100) {
                        n = 0;
                        if (downing) {
                            downing = false;
                            lycms.pageRefresh();
                            clearInterval(timer);
                            othis.removeClass(DISABLED);
                        }
                    }
                    element.progress('downLoad', n + '%');
                }, 300 + Math.random() * 1000);

            othis.addClass(DISABLED);
        }
    };

    exports('lycms', lycms);
})